package learnjava.basic.other;

import java.util.HashMap;
import java.util.HashSet;
import java.util.TreeSet;

public class TestNullAsKey {

    public static void main(String[] args) {

        HashMap<Integer,Integer> hashMap = new HashMap<>();
        HashSet<Integer> hashSet = new HashSet<>();

        hashMap.put(null,0);
        hashSet.add(null);

        System.out.println(hashMap);
        System.out.println(hashSet);

        TreeSet<Integer> treeSet = new TreeSet<>();
        treeSet.add(null); //Exception in thread "main" java.lang.NullPointerException
        System.out.println(treeSet);
    }
}
